//例子1 对象转数组
const obj1 = {
    manualUrl: 'http://xxxx.com/xx',
    expiryDate: '1011-10-01'
};

const result1 = Object.entries(obj1).map(([key, value]) => ({
    name: '',
    key,
    value
}));

console.log(result1); // 输出结果：[ { name: '', key: 'manualUrl', value: 'http://xxxx.com/xx' }, { name: '', key: 'expiryDate', value: '1011-10-01' } ]


//例子2 数组转对象
const arr2 = [
    { name: '说明书链接', key: 'manualUrl', value: 'http://xxxx.com/xx' },
    { name: '有效期', key: 'expiryDate', value: '1011-10-01' }
];

const result2 = arr2.reduce((obj, item) => {
    obj[item.key] = item.value;
    return obj;
}, {});

console.log(result2); // 输出结果：{ manualUrl: 'http://xxxx.com/xx', expiryDate: '1011-10-01' }


//例子3 数组合并对象的值
const arr = [
    { name: '说明书链接', key: 'manualUrl', value: '' },
    { name: '有效期', key: 'expiryDate', value: '' }
];

const obj = {
    manualUrl: 'http://xxxx.com/xx',
    expiryDate: '1011-10-01'
};

arr.forEach(item => {
    if (obj.hasOwnProperty(item.key)) {
        item.value = obj[item.key];
    }
});

console.log(arr); // 输出结果：[ { name: '说明书链接', key: 'manualUrl', value: 'http://xxxx.com/xx' }, { name: '有效期', key: 'expiryDate', value: '1011-10-01' } ]
